package cc.marcio.systems.seven.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "t_message", uniqueConstraints = { @UniqueConstraint(columnNames = { "id" }) })
@SequenceGenerator(name = "seq_message", sequenceName = "seq_message")
public class Message implements Serializable {

	private static final long serialVersionUID = 4735609801503936257L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "seq_message")
	@Column( unique = true, insertable = false, updatable = false )	
	private Long id;
	
	@Basic
    @Temporal(TemporalType.TIMESTAMP)
    @Column(nullable = false)
	private Date date;
	
	@Column( unique = false, nullable = false, insertable = true, updatable = true )
	private String subject;
	
	@Column( unique = false, nullable = false, insertable = true, updatable = true )
	private String message;
	
	@Column( unique = false, nullable = false, insertable = true, updatable = true )
	private Boolean isRead;
	
	@Column( unique = false, nullable = false, insertable = true, updatable = true )
	private Boolean isAlert;
	
	@Column( unique = false, nullable = false, insertable = true, updatable = true )
	private Boolean sendBySite;
	
	@OneToOne
	private User user;
	
	public Message() {
		this.isRead = false;
		this.isAlert = false;
		this.sendBySite = false;
	}

    public Message(Boolean isRead, Boolean isAlert, Boolean sendBySite) {
        this();
        this.isAlert = isAlert;
        this.isRead = isRead;
        this.sendBySite = sendBySite;
    }
	
	public Message(Boolean isRead, Boolean isAlert) {
		this();
		this.isAlert = isAlert;
		this.isRead = isRead;
	}
	
	public Boolean getSendBySite() {
		return sendBySite;
	}

	public void setSendBySite(Boolean sendBySite) {
		this.sendBySite = sendBySite;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Boolean getIsRead() {
		return isRead;
	}

	public void setIsRead(Boolean isRead) {
		this.isRead = isRead;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Boolean getIsAlert() {
		return isAlert;
	}

	public void setIsAlert(Boolean isAlert) {
		this.isAlert = isAlert;
	}
}